load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")
load(
    "//tachyon/math/finite_fields/generator/binary_field_generator:build_defs.bzl",
    "generate_binary_fields",
)

package(default_visibility = ["//visibility:public"])

BITS = [
    1,
    2,
    4,
    8,
    16,
    32,
    64,
    128,
]

[
    generate_binary_fields(
        name = "binary_field{}".format(bit),
        class_name = "BinaryField{}".format(bit),
        modulus = str(1 << bit),
        namespace = "tachyon::math",
    )
    for bit in BITS
]

tachyon_cc_library(
    name = "binary_field",
    hdrs = [
        "binary_field.h",
        "binary_field_traits_forward.h",
        "binary_tower_operations.h",
    ],
    deps = [
        "//tachyon/base:logging",
        "//tachyon/base:random",
        "//tachyon/base/numerics:safe_conversions",
        "//tachyon/base/strings:string_number_conversions",
        "//tachyon/base/strings:string_util",
        "//tachyon/build:build_config",
        "//tachyon/math/finite_fields:finite_field",
        "@com_google_absl//absl/base",
    ],
)

tachyon_cc_library(
    name = "binary_fields",
    hdrs = ["binary_fields.h"],
    # buildifier: leave-alone
    deps = [
        ":binary_field1",
        ":binary_field2",
        ":binary_field4",
        ":binary_field8",
        ":binary_field16",
        ":binary_field32",
        ":binary_field64",
        ":binary_field128",
    ],
)

tachyon_cc_unittest(
    name = "binary_fields_unittests",
    srcs = ["binary_fields_unittest.cc"],
    deps = [":binary_fields"],
)
